package com.winai.launcher.base;

import android.util.SparseArray;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

/**
 * @Auth 康少
 * @Date 2019/7/3 15:57
 * @Desc 视图Holder基类
 */
public class BaseRecViewHolder extends RecyclerView.ViewHolder {
    private SparseArray<View> views;

    public BaseRecViewHolder(View itemView) {
        super(itemView);
        this.views = new SparseArray<>();
    }

    @SuppressWarnings("unchecked")
    public <T extends View> T getView(int viewId) {
        View view = views.get(viewId);
        if (view == null) {
            view = itemView.findViewById(viewId);
            views.put(viewId, view);
        }
        return (T) view;
    }
}
